
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Robin
 */
public class TestKlasseCellRenderer extends JLabel implements ListCellRenderer{

    public TestKlasseCellRenderer(){
        setOpaque(true);
        setIconTextGap(12);
    }
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        TestKlasse tk=(TestKlasse)value;
        String tekst=tk.getOnderwerp()+"\n"+tk.getTekst();
        setText("<html>"+tk.getOnderwerp()+"<br>"+tk.getTekst()+"</html>");
        setIcon(tk.getImage());

            if (isSelected) {
      setBackground(Color.yellow);
      setForeground(Color.white);
    } else {
      setBackground(Color.white);
      setForeground(Color.black);
    }

        return this;
    }

}
